import { Response } from 'express';

/**
 * 成功响应
 * @param res Express响应对象
 * @param data 响应数据
 * @param statusCode HTTP状态码
 */
export const successResponse = (
  res: Response, 
  data: any, 
  statusCode = 200
): void => {
  res.status(statusCode).json({
    success: true,
    data
  });
};

/**
 * 错误响应
 * @param res Express响应对象
 * @param message 错误消息
 * @param statusCode HTTP状态码
 */
export const errorResponse = (
  res: Response, 
  message: string, 
  statusCode = 500
): void => {
  res.status(statusCode).json({
    success: false,
    error: message
  });
};

/**
 * 验证错误响应
 * @param res Express响应对象
 * @param errors 验证错误对象
 */
export const validationErrorResponse = (
  res: Response, 
  errors: any
): void => {
  const messages = Object.values(errors).map((err: any) => err.message);
  
  res.status(400).json({
    success: false,
    error: messages.join(', ')
  });
}; 